package cz.proks.schoolpupilbook.gae.restlet.resource;

import cz.proks.schoolpupilbook.gae.dao.UserCourseRelationDAO;
import cz.proks.schoolpupilbook.shared.domain.UserCourseRelation;
import cz.proks.schoolpupilbook.shared.restlet.RestMapping;

public class UserCourseRelationServerResource extends BaseServerResource implements UserCourseRelationResource{
	private UserCourseRelationDAO dao = new UserCourseRelationDAO();
	
	@Override
	public UserCourseRelation retrieve() {
		String userCourseId = (String) getRequestAttributes().get(RestMapping.PARAMETER_USER_COURSE_RELATION_ID);
				
		if (userCourseId == null || userCourseId.isEmpty())
			return null;
		
		UserCourseRelation userCourseRelation = dao.find(userCourseId);		
		return userCourseRelation;		
	}

	@Override
	public void store(UserCourseRelation obj) {				
		dao.save(obj);
	}
}
